Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixbug: EVPN issue in FRR template #4260

Merged
merged 13 commits into from
Apr 3, 2020

Conversation

Pterosaur
Copy link
Contributor

@Pterosaur Pterosaur commented Mar 13, 2020

- What I did
Fixes EVPN issue in FRR template to avoid the routes that belong to VNet are broadcasted by FRR.

- How I did it
Add interface manager in BGPCFGD daemon to separate the routes that belong to VNet or not according to interface table in config db.

- How to verify it
vtysh -c "show running-config"

- Description for the changelog
Fixes EVPN issue in FRR template to avoid the routes that belong to VNet are broadcasted by FRR.

- A picture of a cute animal (not mandatory but encouraged)
🦏

Signed-off-by: zegan zegan@microsoft.com

Signed-off-by: zegan <zegan@microsoft.com>
Signed-off-by: zegan <zegan@microsoft.com>


class InterfaceMgr(Manager):
def __init__(self, daemon, directory, interface_table = swsscommon.CFG_INTF_TABLE_NAME):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would also want to consider VLAN_INTERFACE as well - CFG_VLAN_INTF_TABLE_NAME

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your suggestion. Have added VlanInterfaceMgr.

Copy link
Contributor

@pavel-shirshov pavel-shirshov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As comments

dockers/docker-fpm-frr/bgpcfgd Outdated Show resolved Hide resolved
dockers/docker-fpm-frr/bgpcfgd Outdated Show resolved Hide resolved
Signed-off-by: zegan <zegan@microsoft.com>
prsunny
prsunny previously approved these changes Mar 16, 2020
@prsunny
Copy link
Contributor

prsunny commented Mar 16, 2020

retest vsimage please

pavel-shirshov
pavel-shirshov previously approved these changes Mar 16, 2020
@lguohan
Copy link
Collaborator

lguohan commented Mar 22, 2020

retest vsimage please

@lguohan
Copy link
Collaborator

lguohan commented Mar 22, 2020

it looks like vs test failed on bgp tests, please check. likely this pr breaks existing functions.

@sonic-net sonic-net deleted a comment from prsunny Mar 22, 2020
@sonic-net sonic-net deleted a comment from prsunny Mar 22, 2020
@sonic-net sonic-net deleted a comment from prsunny Mar 22, 2020
@sonic-net sonic-net deleted a comment from jleveque Mar 22, 2020
@sonic-net sonic-net deleted a comment from prsunny Mar 22, 2020
@lguohan
Copy link
Collaborator

lguohan commented Mar 22, 2020

@Pterosaur, please look into the vsimage test. the pr cannot be merged until the test passing.

Signed-off-by: zegan <zegan@microsoft.com>
@Pterosaur Pterosaur dismissed stale reviews from pavel-shirshov and prsunny via 4c8a4c6 March 25, 2020 18:59
prsunny
prsunny previously approved these changes Mar 25, 2020
@Pterosaur
Copy link
Contributor Author

retest vsimage please

…h set in the same interface

Signed-off-by: zegan <zegan@microsoft.com>
if interface.has_key("vnet_name") and interface["vnet_name"]:
# Ignore the route that is in a vnet
syslog.syslog(syslog.LOG_INFO, 'Peer {} in vnet {}'.format(key, interface["vnet_name"]))
return True
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i finally understood what you are trying to do in this block (spend about 30 minutes)! it is so difficult to understand because people do not understand what local_addresses and interfaces mean. In fact, what you really should do here is to create two functions.
one function is
find_local_interface(ip). The input is a ip address, and return value is interface name. return None if you cannot find a interface.

second function is
check_interface_type(interface_name). You can return vnet interface it is vnet interface, or default if the interface is in default vrf.

since you do not have such abstract, it is difficult for others to understand the code and maintain.

Please put code readability into priority.

@@ -390,6 +420,79 @@ class BGPPeerMgr(Manager):
return peers


def prefix_attr(attr, value):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is really a bad interface design! the function name is generic. in fact the fuction does very specific thing, it assume the value is ip prefix and convert the string into ipnetwork, and then get an attribute, and finally convert it into a string.

to evaulate whether a function provide a good abstraction or not. People should be able to understand the what the function's job by just looking at the function name at the caller without looking into the implementation of the function.

I think you need to either get rid of this function, or have a function get_ip_from_ipprefix function to do the specific job you want.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree with your comment. And I think this is a very common tool function maybe we should extract it to a common python package.
Because we did also use it at : https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-config-engine/sonic-cfggen#L81
Should I do that?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right, that was my miss. it is not a good code.


In reply to: 400696041 [](ancestors = 400696041)

Signed-off-by: zegan <zegan@microsoft.com>
@Pterosaur Pterosaur requested a review from lguohan March 31, 2020 16:16
Signed-off-by: zegan <zegan@microsoft.com>
@Pterosaur Pterosaur requested a review from lguohan April 1, 2020 02:22
Signed-off-by: zegan <zegan@microsoft.com>
# So we need to check whether this bgp session belongs to a vnet.
interface = InterfaceMgr.get_local_interface(self.directory, data["local_addr"])
if not interface:
return False
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what should be the log message here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this is an intermediate state. Maybe it should add some log with INFO level to display this state. Same problem at here https://github.com/Azure/sonic-buildimage/blob/master/dockers/docker-fpm-frr/bgpcfgd#L295

Signed-off-by: zegan <zegan@microsoft.com>
Signed-off-by: zegan <zegan@microsoft.com>
Signed-off-by: zegan <zegan@microsoft.com>
@Pterosaur Pterosaur requested a review from lguohan April 1, 2020 15:14
@Pterosaur
Copy link
Contributor Author

retest vsimage please

@lguohan
Copy link
Collaborator

lguohan commented Apr 1, 2020

can you add more description in the commit message?

@prsunny
Copy link
Contributor

prsunny commented Apr 2, 2020

retest vsimage please

@prsunny prsunny merged commit ea38d06 into sonic-net:master Apr 3, 2020
@Pterosaur Pterosaur deleted the fix_frr_evpn_template branch April 3, 2020 05:08
abdosi pushed a commit that referenced this pull request Apr 3, 2020
* Fixbug: EVPN issue in FRR template
tiantianlv pushed a commit to SONIC-DEV/sonic-buildimage that referenced this pull request Apr 24, 2020
* Fixbug: EVPN issue in FRR template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants